<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.1.0/jquery.js"></script>
  </head>
  <body>
    <form>
      用户名：<input type="text" id="user" /><br />
      密码：<input type="password" id="pwd" /><br />
      <button type="button">提交</button>
    </form>
    <script>
      $("button").click(function () {
        $.ajax({
          url: "http://127.0.0.1/addUser",
          type: "post",
          data: {
            username: $("#user").val().trim(),
            password: $("#pwd").val().trim()
          },
          success: function (res) {
            if (res.status === 0) {
              $("#user").val("");
              $("#pwd").val("");
              location.href = "1.html";
            }
          }
        });
      });
    </script>
  </body>
</html>
